//
//  main.cpp
//  P1047
//
//  Created by 洋犀利 on 2019/8/30.
//  Copyright © 2019 洋犀利. All rights reserved.
//

#include <iostream>
using namespace std;
int length;
int trees[10001] = {0};
int tree;
int areaN;
int b;
int e;
int area[101] = {0};

int main(int argc, const char * argv[]) {
    for(int i=0;i<101 && area[i] !=0;i++){
        
 }
    cin>>length>>areaN;
    tree = length+1;
    for(int i=0;i<tree;i++){
        trees[i] = 1;
    }
    tree = 0;
    for(int i=0;i<areaN;i++){
        cin>>b>>e;
        for(int j=b;j<=e;j++){
            trees[j] = 0;
        }
        b=0;
        e=0;
    }
    for(int i=0;i<10001;i++){
        if(trees[i] ==1)
        tree+=1;
    }
    cout<<tree;
    
    return 0;
}
